package fruitsManage;

/**
 * 进货记录
 * 
 * @author 伟❤志
 *
 */
public class PurchaseModel {

	private String fruitName;// 水果名
	private double fruitBid;// 进价
	private double quantity;// 进货量

	public String getFruitName() {
		return fruitName;
	}

	public void setFruitName(String fruitName) {
		this.fruitName = fruitName;
	}

	public double getFruitBid() {
		return fruitBid;
	}

	public void setFruitBid(double fruitBid) {
		this.fruitBid = fruitBid;
	}

	public double getQuantity() {
		return quantity;
	}

	public void setQuantity(double quantity) {
		this.quantity = quantity;
	}

	/**
	 * 查询所有进货信息
	 * 
	 * @param name
	 */
	public void selectAll() {
		for (PurchaseModel purchaseModel : Purchase.purchase) {
			purchaseInfo(purchaseModel);
		}
	}

	/**
	 * 根据水果名查询该水果的进货记录
	 * 
	 * @param name
	 */
	public void selectByName(String name) {
		for (PurchaseModel purchaseModel : Purchase.purchase) {
			if (name.equals(purchaseModel.getFruitName())) {
				purchaseInfo(purchaseModel);
			}
		}
	}

	/**
	 * 进货信息
	 * 
	 * @param purchaseModel
	 */
	public void purchaseInfo(PurchaseModel purchaseModel) {

		System.out.println("=================");
		System.out.println("水果名：" + purchaseModel.getFruitName());
		System.out.println("进价：" + purchaseModel.getFruitBid() + "元/斤");
		System.out.println("进货量：" + purchaseModel.getQuantity() + "斤");
		System.out.println("=================");

	}

	/**
	 * 添加进货信息
	 * 
	 * @param name
	 * @param stock
	 * @param price
	 * @param bid
	 */
	public void addShop(String name, double stock, double price, double bid) {

		FruitsModel fruitsModel = new FruitsModel();
		PurchaseModel purchaseModel = new PurchaseModel();

		purchaseModel.setFruitName(name);
		purchaseModel.setFruitBid(bid);
		purchaseModel.setQuantity(stock);

		Purchase.purchase.add(purchaseModel);

		fruitsModel.addFruits(name, stock, price, bid);
	}
}
